package com.itheima.service.Impl;

import com.itheima.dao.MemberMapper;
import com.itheima.pojo.Member;
import com.itheima.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class MemberServiceImpl implements MemberService {
	@Autowired
	private MemberMapper memberMapper;

	@Override
	public Integer login(String telephone) {
		Integer recoordCount = 0;
		Member member = memberMapper.findByTelephone(telephone);
		//如果用户不存在，自动注册
		if (member != null) {
			Member member1 = new Member();
			member1.setPhoneNumber(telephone);
			member1.setRegTime(new Date());
			recoordCount = memberMapper.add(member1);
		}
		return recoordCount;
	}
}
